1. Field of the Invention
The present invention relates to a simulation system and method for a microcomputer program.
2. Description of Related Art
In order to operate a hardware in a microcomputer, a program is indispensable which instructs an operation of the microcomputer. In developing a program, it is necessary to ascertain or verify the operation based on the program by actually executing the program on the hardware on which the program is to be caused to run, in order to ascertain that the program properly operates, and in order to investigate a cause when the program does not properly operate. However, when the program cannot be executed on an actual hardware, as in one case where the program is developed concurrently with and in parallel with the development of hardware, and therefore, the operation based on the program cannot be ascertained until the hardware is completed, and as in another case where the hardware is expensive and the operation ascertainment or verification incurs a large cost. To resolve this problem, there is adopted a simulation method of performing the operation ascertainment or verification by executing the program under development, on a hardware different from the hardware on which the program under development is to be caused to run.
For example, Japanese Patent Application Pre-examination Publication No. JP-A-06-208480, (an English abstract of JP-A-06-208480 is available from the Japanese Patent Office, and the content of the English abstract of JP-A-06-208480 is incorporated by reference in its entirety into this application) discloses one prior art simulation method in which an operation verification is executed by operating a plurality of simulation means controlled by a control means.
Referring to FIG. 1, there is shown a block diagram of a system for performing the prior art simulation method disclosed by the above referred patent publication.
The shown simulation system includes a keyboard 100, a computer 101, a simulation information hold memory 106 and a display 108, which are coupled as shown. The computer 101 internally includes an input analysis means 102, a simulation control means 103, a machine language instruction execution simulation means 104, a peripheral circuit simulation means 105 and a simulation information indication means 107, which are coupled as shown.
An input content of the keyboard 100, which represents the directions given from a program developer, are supplied to the input analysis means 102 of the microcomputer 101. The input analysis means 102 analyzes the directions supplied through the keyboard 100. When the directions indicate execution of the simulation, the input analysis means 102 supplies the received directions to the simulation control means 103, and when the directions indicates an information indication, the input analysis means 102 supplies the received directions to the simulation information indication means 107.
The simulation control means 103 controls execution and stop of simulation in each of the machine language instruction execution simulation means 104 and the peripheral circuit simulation means 105. The machine language instruction execution simulation means 104 executes a program prepared by the program developer, sequentially at a machine language level. The peripheral circuit simulation means 105 simulates a peripheral circuit of the microcomputer. Here, the peripheral circuit of the microcomputer realizes, for example, a timer function and a communication function, which are effective for control of the hardware.
The simulation information hold memory 106 stores information of the machine language instruction execution simulation means 104 and the peripheral circuit simulation means 105 when the simulation is executed. The simulation information hold memory 106 includes therein a special function register (not shown), and the peripheral circuit simulation means 105 is controlled by the content of the special function register written by the machine language instruction execution simulation means 104.
The simulation information indication means 107 fetches information from the simulation information hold memory 106 in accordance with the directions supplied from the input analysis means 102 and the simulation control means 103, and controls the display 108 to cause the display 108 to display the fetched information. Namely, the display 108 displays the information supplied from the simulation information indication means 107.
Here, in the case of ascertaining the operation based on a program for controlling a system including a peripheral device, it is meaningless to simulate only the program. It is important in the operation ascertainment, to simulate the input/output of the peripheral device. Because of this, the peripheral circuit simulation means 105 for simulating the operation of the peripheral device, is caused to operate concurrently with the machine language instruction execution simulation means 104, so that the simulation including an interaction between these means is realized. In this case, the input/output of data and various commands of respective means is simulated by using the simulation information hold memory 106 as a common memory, with the result that simulation of each means cannot be executed independently of the other means.
In the prior art simulation method, therefore, the peripheral circuit simulation and the machine language instruction execution simulation are alternately executed within each one simulation unit time under the control of the simulation control means 103, in order to ensure such a condition that, when the processing of the simulation of one means has an influence on the operation of the simulation of the other means, after the processing of the simulation of the one means has been completed, the simulation of the other means is executed. Here, the simulation time unit is defined by a minimum unitary time in which the simulation is executed, and corresponds to an operation clock or an instruction execution clock in a microcomputer which is a simulation target.
Referring to FIG. 2, there is shown a flow chart illustrating the operation of various parts in the microcomputer 101 in the prior art simulation system. Now, the procedure of the prior art simulation method will be described with reference to FIG. 2.
If the directions for execution of the simulation are supplied from the input analysis means 102 to the simulation control means 103, the simulation control means 103 outputs the directions for execution of the peripheral circuit simulation in one simulation unit time, to the peripheral circuit simulation means 105 (step 1200). If the peripheral circuit simulation is completed, the simulation control means 103 ascertains whether or not an interrupt has been generated as the result (step 1201). If the interrupt has been generated, the processing for stating the interrupt is executed (step 1202), and thereafter, the directions for start of the machine language instruction execution simulation in one simulation unit time are outputted to the machine language instruction execution simulation means 104 (step 1203). If it is ascertained in the step 1201 that the interrupt has not been generated, the directions for start of the machine language instruction execution simulation in one simulation unit time are outputted to the machine language instruction execution simulation means 104 without executing the processing for starting the interrupt. If the machine language instruction execution simulation is completed, since the respective simulations within one simulation unit time have been completed, the simulation control means 102 ascertains whether the simulation should be ended or continued (step 1204). If the simulation should be ended, the processing is completed. On the other hand, if the simulation should be continued, the operation is returned to the first processing (namely, the step 1200).
A cause for deciding in the step 1204 that the simulation should be ended, includes an interruption attributable to a break point, and an interruption ordered by a user. The break point is a location where a break command is inserted for stopping the program in a software manner.
In the above mentioned prior art simulation method, since the respective simulations are alternately executed within each one simulation unit time, even if there occurs an operation such as an interrupt which gives influence on the operation of the other simulation means, the processing for the interrupt can be immediately executed, with the result that the respective simulations can be exactly executed.
On the other hand, since the peripheral circuit simulation and the machine language instruction execution simulation are alternately executed within each one simulation unit time, there is a problem that the simulation speed is low because of an overhead such as communication between the respective simulation means and a preprocessing.